package org.budo.redis.jdbc.driver;

import java.sql.SQLException;
import java.sql.Types;

import org.budo.jdbc.driver.AbstractBudoJdbcResultSetMetaData;

/**
 * @author lmw
 */
public class BudoRedisJdbcResultSetMetaData extends AbstractBudoJdbcResultSetMetaData {
    private String[] columnNames;

    public BudoRedisJdbcResultSetMetaData() {}

    public BudoRedisJdbcResultSetMetaData(String[] columnNames) {
        this.setColumnNames(columnNames);
    }

    public int getScale(int column) throws SQLException {
        return 0;
    }

    public int getPrecision(int column) throws SQLException {
        return 0;
    }

    public void setColumnNames(String[] columnNames) {
        this.columnNames = columnNames;
    }

    @Override
    public String getColumnName(int column) throws SQLException {
        String[] columnNames = this.columnNames;
        return columnNames[column - 1];
    }

    @Override
    public int getColumnCount() throws SQLException {
        String[] columnNames = this.columnNames;
        return columnNames.length;
    }

    @Override
    public String getColumnLabel(int column) throws SQLException {
        return this.getColumnName(column);
    }

    @Override
    public int getColumnType(int column) throws SQLException {
        return Types.VARCHAR;
    }

    @Override
    public String getColumnClassName(int column) throws SQLException {
        return String.class.getName();
    }

    @Override
    public String getSchemaName(int column) throws SQLException {
        return "";
    }

    @Override
    public String getTableName(int column) throws SQLException {
        return "";
    }

    @Override
    public int getColumnDisplaySize(int column) throws SQLException {
        return Integer.MAX_VALUE;
    }
}
